import * as fs from 'fs';

let configFilePath = '';

export function watchConfigFileModification(filePath: string, callback?: () => void) {
  configFilePath = filePath;

  fs.watchFile(configFilePath, (curr, prev) => {
    if (curr.mtime === prev.mtime) {return;}
    callback?.();
  });
}

export function stopWatchConfigFileModification() {
  fs.unwatchFile(configFilePath);
}